package com.caiden_micheal.base.domain;


import com.caiden_micheal.base.constant.ResultCode;
import lombok.Data;

@Data
public class AjxResult<T> {
    private Integer code;
    private String msg;
    private T data;

    public AjxResult(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static AjxResult success(Object msg) {
        return new AjxResult(ResultCode.SUCCESS.code, ResultCode.SUCCESS.message, msg);
    }

    public static AjxResult fileNotFound(String filePath) {
        return new AjxResult(ResultCode.FILE_NOT_FOUNT.code, ResultCode.FILE_NOT_FOUNT.message, filePath);
    }

    public static AjxResult printerNotFound(String printerName) {
        return new AjxResult(ResultCode.PRINTER_NOT_FOUNT.code, ResultCode.PRINTER_NOT_FOUNT.message, printerName);
    }

    public static AjxResult unknownError(String error) {
        return new AjxResult(ResultCode.UNKNOWN_Error.code, ResultCode.UNKNOWN_Error.message, error);
    }

    public static AjxResult jwtError(String error) {
        return new AjxResult(ResultCode.JWT_TOKEN_Error.code, ResultCode.JWT_TOKEN_Error.message, error);
    }

    public static AjxResult userNotFound(String error) {
        return new AjxResult(ResultCode.USER_NOT_FOUNT.code, ResultCode.USER_NOT_FOUNT.message, error);
    }

    public static AjxResult passwordError(String error) {
        return new AjxResult(ResultCode.PASSWORD_Error.code, ResultCode.PASSWORD_Error.message, error);
    }

    public static AjxResult paramError(String error) {
        return new AjxResult(ResultCode.PARAM_Error.code, ResultCode.PARAM_Error.message, error);
    }

    public static AjxResult requestTimeOut(String error) {
        return new AjxResult(ResultCode.REQUEST_TIME_OUT_Error.code, ResultCode.REQUEST_TIME_OUT_Error.message, error);
    }

    public static AjxResult emailRepeat(String error) {
        return new AjxResult(ResultCode.EMAIL_REPEAT_Error.code, ResultCode.EMAIL_REPEAT_Error.message, error);
    }

    public static AjxResult userNameRepeat(String error) {
        return new AjxResult(ResultCode.USERNAME_REPEAT_Error.code, ResultCode.USERNAME_REPEAT_Error.message, error);
    }

    public static AjxResult userIsAbnormal(String error) {
        return new AjxResult(ResultCode.USER_IS_ABNORMAL_Warn.code, ResultCode.USER_IS_ABNORMAL_Warn.message, error);

    }

    public static AjxResult emailSendError(String error) {
        return new AjxResult(ResultCode.EMAIL_SEND_Error.code, ResultCode.EMAIL_SEND_Error.message, error);
    }

    public static AjxResult unAuthorizedAccess(String error) {
        return new AjxResult(ResultCode.UnAuthorized_Error.code, ResultCode.UnAuthorized_Error.message, error);
    }

    public static AjxResult repetitiveError(String error){
        return new AjxResult(ResultCode.Repetitive_Error.code, ResultCode.Repetitive_Error.message, error);
    }

    public static AjxResult processError(String error) {
        return new AjxResult(ResultCode.Process_Error.code, ResultCode.Process_Error.message, error);
    }
}